package com.crocodileQ.controller;

import com.crocodileQ.common.R;
import com.crocodileQ.domain.entity.User;
import com.crocodileQ.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
@Api(tags = "用户",description = "用户相关接口")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 用户信息查询
     * @return
     */
    @ApiOperation(value = "用户信息",notes = "获取当前用户信息")
    @GetMapping("/userInfo")
    public R userInfo(){

        return userService.userInfo();
    }


    /**
     * 更新用户信息查询
     * @return
     */
    @PutMapping("/userInfo")
    @ApiImplicitParam(name="user",value = "用户实体类")
    public R<String> userInfo(@RequestBody User user){

        return userService.updateUserInfo(user);
    }

    /**
     * 用户注册
     * @param user
     * @return
     */
    @PostMapping("/register")
    public R<String> register(User user){

        return userService.register(user);
    }
}
